package com.mingqi.enetconnected.primary.mytask.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.github.chrisbanes.photoview.PhotoView;

import java.util.List;

/**
 * @author li
 * @version 1.0
 * @describe
 * @WeChat 18571658038
 * @date 2018/9/14 星期五.
 */

public class EquityPageAdapter extends PagerAdapter {

    private List<PhotoView> ivList;

    public EquityPageAdapter(List<PhotoView> ivList) {

        this.ivList = ivList;
    }

    /**
     * @return 返回页面的个数
     */
    @Override
    public int getCount() {

        return ivList == null ? 0 : ivList.size();
    }

    /**
     * 判断对象是否生成界面
     * @param view
     * @param object
     * @return
     */
    @Override
    public boolean isViewFromObject(View view, Object object) {

        return view == object;
    }

    /**
     * 初始化position位置的界面
     * @param container
     * @param position
     * @return
     */
    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        //使图片实现可以放大缩小的功能
        container.addView(ivList.get(position));
        return ivList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        container.removeView(ivList.get(position));
    }
}
